package top.scsoul.pas.utils;


import top.scsoul.pas.bean.ClazzPerformanceAnalysisBean;
import top.scsoul.pas.entity.Achievement;
import top.scsoul.pas.entity.Student;

import java.util.ArrayList;
import java.util.List;

public class PerformanceAnalysisUtil {
    public static List<ClazzPerformanceAnalysisBean> ClazzPerformanceAnalysis(List<Achievement> achievements) {
        ArrayList<ClazzPerformanceAnalysisBean> list = new ArrayList<>();
        achievements.forEach(achievement -> {
            Student student = achievement.getStudent();
            Long id = student.getId();
            String name = student.getName();
            Integer type = achievement.getExamInfo().getClazzes().get(0).getType();
            ClazzPerformanceAnalysisBean clazzPerformanceAnalysisBean = new ClazzPerformanceAnalysisBean();
            float ysyt = achievement.getChinese() + achievement.getMath() + achievement.getEnglish();
            clazzPerformanceAnalysisBean.setMainTotal(ysyt);
            //语数英平均分
            clazzPerformanceAnalysisBean.setMainAvg(ysyt / 3);
            if (type == 0) {
                //文科
                float wt = achievement.getPolitics() + achievement.getHistory() + achievement.getGeography();
                clazzPerformanceAnalysisBean.setTotal(ysyt + wt);
                clazzPerformanceAnalysisBean.setLiberalArtsTotal(wt);
                clazzPerformanceAnalysisBean.setLiberalArtsAvg(wt / 3);
            } else if (type == 1) {
                //理科
                System.out.println(ysyt);
                float lt = achievement.getPhysics() + achievement.getChemistry() + achievement.getBiology();
                clazzPerformanceAnalysisBean.setTotal(ysyt + lt);
                clazzPerformanceAnalysisBean.setScienceTotal(lt);
                clazzPerformanceAnalysisBean.setScienceAvg(lt / 3);
            }
            list.add(clazzPerformanceAnalysisBean);
        });
        return list;
    }
}

